<?php
   // include function files for this application
   require_once('/home/domains/uny-con.com/public_html/uny-con_fns.php');
   if (!session_id()) { session_start(); }

/*
   if (!check_valid_user()) {
      // they are not logged in 
      do_html_header('You must be logged in', staysmall);
      echo 'You are not logged in.<br />';
      do_html_url('login.php', 'Login');
      print_brs(6);
      do_html_footer(news);
      exit;
   }
*/
/*
//We don't want people accessing this page during the con.

if (!check_valid_user() || ($_SESSION['admin'] != 't')) {
	do_html_header('Unauthorized access', staysmall, $uny);
	echo 'We are sorry, Event sign-up is not yet available. Registration for events will be available on September 20th.';
	print_brs(24);
	do_html_footer(news);
	exit;
	}
*/


$event_type = $_GET['event_type'];
if (isset($_GET['sortkey'])) $sortkey = $_GET['sortkey'];
	else $sortkey = 'event.event_type, event.game_system' ;
if (isset($_GET['sortdir'])) $sortdir = $_GET['sortdir'];
	else $sortdir = 'ASC' ;
if (isset($_GET['searchtype'])) $searchtype = $_GET['searchtype'];
	else $searchtype = 'all' ;
if (isset($_GET['search_key'])) $search_key = $_GET['search_key'];
if (isset($_GET['searchterm'])) $search_string = $_GET['searchterm'];

if (isset($_POST) && !empty($_POST)) $searchtype = search ;
if (isset($_POST['search_key']) && !empty($_POST['search_key'])) $search_key = $_POST['search_key'];
if (isset($_POST['search_string']) && !empty($_POST['search_string'])) {
	if ($_POST['search_key'] == 'event.event_title' || $_POST['search_key'] == 'event.event_type' || $_POST['search_key'] == 'event.game_system') {
		$search_string = '%'.$_POST['search_string'].'%' ;
		} else {
		$search_string = $_POST['search_string'] ;
		}
	} elseif (!empty($_POST) && isset($_POST)) {
	$search_string = '%' ;
	}

do_html_header("$event_type Event Signup", gobig, $uny);


	echo '<p>Below is the list of events matching your search criteria. If you would like to sign-up to play in an event click on the play link in the Signup column. If you are signing up to GM an event click the GM link in the signup columnn.</p>';
	
	print_event_search_form();
	print_event_table(get_event_list($searchtype, $search_key, $search_string, $sortkey, $sortdir));
do_html_footer(no_news);

?>